<template>
	<view class="complaints">
		<u-form class="complaints-form" :model="form" ref="form" :error-type="['toast']">
			<u-form-item class="complaints-form_item" prop="complaints" :label="$t('mine.complaints_tip')"
				label-position="top">
				<u-input height="120" type="textarea" :border="true" v-model="form.feedback" :placeholder="$t('mine.pub_tips')" />
			</u-form-item>
		</u-form>
		<view class="complaints-button">
			<u-button type="primary" @click="submit">{{$t('mine.btn_save')}}</u-button>
		</view>
	</view>
</template>

<script>
import store from '@/store/index.js';
import pageMixin from '@/utils/pageMixin';
export default {
  mixins: [pageMixin],
		data() {
			return {
				form: {
					uid: 0,
					feedback: '',
				},
				iconStyle: {
					fontSize: '38rpx',
					color: '#646466',
					display: 'flex'
				},
			}
		},

		onLoad(option) {
			this.userUid = store.state.vuex_user.uid
			uni.setNavigationBarTitle({
				title: this.$t('home.btn_report')
			});
			this.form.uid = parseInt(option.uid) || 0;
		},
		onShow() {},
		onReady() {

		},
		components: {},
		computed: {
			i18n() {
				return this.$t('mine')
			}
		},
		methods: {
			submit() {
			    let that = this;
				this.$store.commit('checkUserLogin');
				if (that.form.content == '') {
			        uni.showToast({
			            title: that.$t('mine.pub_tips'),
						icon: 'none'
			        });
					return;
				}
				that.form.uid = this.userUid;
			    that.$http.post('/client/user/account/feedback/save', that.form, that.jHeader).then(res => {
			        uni.showToast({
			            title: this.$t('mine.submit_success'),
			        });
					that.form.feedback = "";
					setTimeout(function () {
						that.$u.route({
							type: 'back',
							delta: 1
						});
					}, 1000)
			    });
			},
		}
	}
</script>

<style lang="scss" scoped>
	.complaints {
		height: 100vh;
		background-color: #ffffff;
	}

	.complaints-form {
		padding: 0 30rpx;
		margin-bottom: 20rpx;
	}

	.complaints-form_item::after {
		border: none;
	}

	.complaints-button {
		padding: 0 80rpx;
	}
</style>
